#ifndef PACMAN_H
#define PACMAN_H

#include <QObject>
#include<QPainter>
#include<QStack>
//#include<iostream>
#include<functional>
//#include<QFunctionPointer>
#include<QHash>
using namespace std;

enum class Direction:int{
    UP,
    DOWN,
    LEFT,
    RIGHT
};

template<class T>
struct MotionFunction
{
public:
    int x;
    int y;
    function<T> f;
    QStack<double> initialParams;
};


class Pacman:public QObject
{
    Q_OBJECT
public:
    Pacman(int x,int y,int w,int h,QString pic);

    virtual void draw(QPainter& p);

    virtual void setPos(int x,int y);

    virtual int &rx();
    virtual int &ry();

    virtual int &rOriginX();
    virtual int &rOriginY();

    virtual void setFace(const Direction &d,QPixmap pic);

    virtual void setDirection(const Direction &d,int distance);

    virtual QHash<Direction,QPixmap> &face();

public:
    MotionFunction<void()> mf;



protected:
    QPixmap pic;
//    QString pic;
    int originX;
    int originY;
    int x;
    int y;
    int width;
    int height;
    Direction direction;


    QHash<Direction,QPixmap> faces;


};

uint qHash(const Direction &d,uint seed);


class Enemy:public Pacman{
    Q_OBJECT
public:
    Enemy(int x,int y,int w,int h,QString pic);
};

class Food:public Pacman{
    Q_OBJECT
public:
    Food(int x,int y,int w,int h,QString pic);



};


#endif // PACMAN_H
